{% extends "scheduling/base.html" %}
{% load static %}

{% block content %}
<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2><i class="fas fa-user-tie me-2"></i>司机管理</h2>
        <a href="{% url 'add_driver' %}" class="btn btn-primary">
            <i class="fas fa-plus-circle me-2"></i>添加司机
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead class="table-light">
                        <tr>
                            <th>工号</th>
                            <th>姓名</th>
                            <th>驾照类型</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for driver in drivers %}
                        <tr>
                            <td>{{ driver.driver_id }}</td>
                            <td>{{ driver.name }}</td>
                            <td>{{ driver.get_license_display }}</td>
                            <td>
                                {% if driver.status == 'on_duty' %}
                                <span class="badge bg-success">在岗</span>
                                {% else %}
                                <span class="badge bg-secondary">休假</span>
                                {% endif %}
                            </td>
                            <td>
                                <a href="{% url 'edit_driver' driver_id=driver.driver_id %}" class="btn btn-sm btn-outline-primary">
                                    <i class="fas fa-edit"></i> 编辑
                                </a>
                                <a href="{% url 'delete_driver' driver_id=driver.driver_id %}" class="btn btn-sm btn-outline-danger">
                                    <i class="fas fa-trash-alt"></i> 删除
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="5" class="text-center py-4">暂无司机数据</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}